<?

/* 		SOCIAL: LASTFM
*/


class LASTFM extends SOCIAL {  


	public function __construct() {
		global $DB;
		
		// get last.fm username and key from settings
		$this->_addvars( engine_get('json:social.lastfm.account') );
		
		// create lastfmapi object (ext)
		$this->initialize();
	}
	
	
	private function initialize() {
	
		// initialize lastfmapi
		include_once( ROOT . 'engine/ext/Last.fm/lastfmapi.php' );
			
		// auth data
		$this->authVars = array (
			'apiKey' => $this->apikey,
			'secret' => '',
			'username' => $this->username,
			'sessionKey' => '',
			'subscriber' => ''
		);
		// config data
		$this->config = array(
			'enabled' => true,
			'path' => ROOT . 'engine/ext/Last.fm/',
			'cache_length' => 1800
		);
		
		// pass the array to the auth class to return a valid auth
		$this->auth = new lastfmApiAuth( 'setsession', $this->authVars );
		
		// create lastfmapi object
		$this->fm = new lastfmApi();
	}
	
	
	public function get_data( $type, $value, $method ) {
	
		// call the package class
		$packageClass = $this->fm->getPackage( $this->auth, $type, $this->config );
		
		// setup the variables
		$methodVars = array(
			'artist' => $value
		);
		
		if ( $data = @$packageClass->{ $method }( $methodVars ) ) return $data;
		//die( '<b>Error '. $packageClass->error['code'] .' - </b><i>'. $packageClass->error['desc'] .'</i>' );
	}
	
	
	public function getPackage( $auth, $type, $config ) {
	
		$return = $this->fm->getPackage( $auth, $type, $config );
		return $return;
	
	}
	
	
}


?>